//Sequelize是一款基于Nodejs功能强大的异步ORM框架。

const Sequelize = require('sequelize');
const config = require('../config/config')
//连接数据库
const sequelize = new Sequelize(config.database, config.username, "", {
  host: config.host,
  dialect: config.dialect,

  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  },

  operatorsAliases: false
});

sequelize
  .authenticate()
  .then(() => {
    console.log('Connection has been established successfully.');
  })
  .catch(err => {
    console.error('Unable to connect to the database:', err);
  });


module.exports = sequelize;
